export function FF(nums: number[], max: number): number[][] {
  const open: { cap: number; index: number[] }[] = [];

  nums.forEach((v) => {
    while (!f()) {
      open.push({ cap: 0, index: [] });
    }
    function f() {
      for (const b of open) {
        if (b.cap + v <= max) {
          b.cap += v;
          b.index.push(v);
          return true;
        }
      }
      return false;
    }
  });

  return open.map((v) => v.index);
}
